<!--conf
<sample>
              <product version="1.4" edition="pro"/>
                     <modifications>
                            <modified date="070101"/>
                     </modifications>
               </sample>
 --> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Operations with clipboard</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
	<script src="../../../codebase/dhtmlx.js"></script>
	<script>
		function copyData(type,delim){
			mygrid.setCSVDelimiter(delim)
			if(type=="all"){//copy entire grid
				mygrid.gridToClipboard();
			}else if(type=="srows"){//selected row
				mygrid.rowToClipboard();
			}else if(type=="cell"){//single cell
				mygrid.cellToClipboard();
			}
		}
		function serilaizeToCSVWithDelim(delim){
			mygrid.setCSVDelimiter(delim)
			document.getElementById('ser_1').value=mygrid.serializeToCSV();
		}
	</script>
</head>

<body>
	<h1>Operations with clipboard</h1>
	<div id="gridbox" style="width:600px;height:200px;background-color:white;overflow:hidden"></div>
	<div>
	<h4>Use as delimiter:</h4>
	<ul>
	<li hrei><a href="javascript:void(0)" onclick="serilaizeToCSVWithDelim('\t')">Tab</a> - \t</li>
	<li><a href="javascript:void(0)" onclick="serilaizeToCSVWithDelim(',')">Comma</a> - ,</li>
	<li><a href="javascript:void(0)" onclick="serilaizeToCSVWithDelim(document.getElementById('serdelim').value)">Other</a> <input id="serdelim" size="1" maxlength="1"></li>
	</ul>
	</div>

	<div>
	<h4>Copy</h4>
	<ul>
	<li><a href="javascript:void(0)" onclick="copyData('all','\t')">Copy entire grid (with tab as delimiter) to clipboard</a></li>
	<li><a href="javascript:void(0)" onclick="copyData('srows','\t')">Copy selected row(s) to clipboard</a></li>
	<li><a href="javascript:void(0)" onclick="copyData('cell','\t')">Copy selected cell to clipboard</a></li>
	</ul>
	</div>

	<div>
	<h4>Paste CSV content to Grid</h4>
	<ul>
	<li><a href="javascript:void(0)" onclick="mygrid.clearAll(); mygrid.gridFromClipboard();">Load grid from clipboard</a></li>
	<li><a href="javascript:void(0)" onclick="mygrid.updateRowFromClipboard();">Update selected row from clipboard</a></li>
	<li><a href="javascript:void(0)" onclick="mygrid.addRowFromClipboard();">Add row(s) from clipboard</li>
	<li><a href="#" onclick="mygrid.updateCellFromClipboard();">Update selected cell from clipboard</a></li>
	</ul>
	</div>

<textarea style="font-size:8pt; font-family:Arial; width:800px; height:150px;" id="ser_1"></textarea>
	
<p>Note: FireFox doesn't allow clipboard activity by default</p>

<script>
   mygrid = new dhtmlXGridObject('gridbox');
   mygrid.setImagePath("../../../codebase/imgs/");
   mygrid.setHeader("Sales,Book Title,Author,Price,In Store,Shipping,Bestseller,Date of Publication");
   mygrid.setInitWidths("50,150,100,80,80,80,80,200")
   mygrid.setColAlign("right,left,left,right,center,left,center,center")
   mygrid.setColTypes("dyn,ed,ed,price,ch,co,ra,ro");
   mygrid.getCombo(5).put(2,2);
   mygrid.enableMultiselect(true)
   mygrid.setSkin("dhx_skyblue")
   mygrid.init();
	mygrid.splitAt(1);
   mygrid.loadXML("../common/grid.xml");
   
window.onerror=function(){
	alert("Clipboard operations not enabled in your browser.");
	window.open("http://www.febooti.com/support/website-help/website-javascript-copy-clipboard.html","_blank");
}
</script>



</body>
</html>
